package com.example.siyun.controller.ordercontroller;

import com.example.siyun.pojo.SyUserOrder;
import com.example.siyun.service.orderservice.RefundService;
import com.example.siyun.util.JsonResult;
import com.example.siyun.util.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 退货列表
 *@author：王浩宇
 *@Date: 2022-10-12
 * */
@RestController
@RequestMapping("/refund")
@Slf4j
public class RefundController {

    @Autowired
    private RefundService refundService;

    /**
     * 退货列表
     * @page:页数
     * @limit:条数
     * @return: 退货列表数据
     * */
    @RequestMapping("/get")
    public PageResult<List> get(Integer page, Integer limit){
        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyUserOrder> all = refundService.Get();

        PageInfo<SyUserOrder> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     * 退货列表搜索
     * @orderSource:支付方式
     * @orderStatus:订单状态
     * @orderPaymentChannel:订单来源
     * @page:页数
     * @limit:条数
     * @return: 退货列表数据
     * */
    @RequestMapping("/select")
    public PageResult<List> select(String orderSource, String orderStatus, String orderPaymentChannel,Integer page, Integer limit){

        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyUserOrder> all = refundService.Select(orderSource,orderStatus,orderPaymentChannel);

        PageInfo<SyUserOrder> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     * 退货申请待处理数据
     * @page:页数
     * @limit:条数
     * @return: 退货申请待处理数据
     * */
    @RequestMapping("/getReturnRequest")
    public PageResult<List> getReturnRequest(Integer page, Integer limit){
        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyUserOrder> all = refundService.getReturnRequest();

        PageInfo<SyUserOrder> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     * 退货申请待处理搜索
     * @orderSource:支付方式
     * @orderStatus:订单状态
     * @orderPaymentChannel:订单来源
     * @page:页数
     * @limit:条数
     * @return: 退货申请待处理数据
     * */
    @RequestMapping("/selectReturnRequest")
    public PageResult<List> selectReturnRequest(String orderSource, String orderStatus, String orderPaymentChannel,Integer page, Integer limit){

        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyUserOrder> all = refundService.selectReturnRequest(orderSource,orderStatus,orderPaymentChannel);

        PageInfo<SyUserOrder> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }

    /**
     * 退货申请已拒绝数据
     * @page:页数
     * @limit:条数
     * @return: 退货申请已拒绝数据
     * */
    @RequestMapping("/getRefuse")
    public PageResult<List> getRefuse(Integer page, Integer limit){
        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyUserOrder> all = refundService.getRefuse();

        PageInfo<SyUserOrder> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     * 退货申请已拒绝搜索
     * @orderSource:支付方式
     * @orderStatus:订单状态
     * @orderPaymentChannel:订单来源
     * @page:页数
     * @limit:条数
     * @return: 退货申请已拒绝数据
     * */
    @RequestMapping("/selectRefuse")
    public PageResult<List> selectRefuse(String orderSource, String orderStatus, String orderPaymentChannel,Integer page, Integer limit){

        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyUserOrder> all = refundService.selectRefuse(orderSource,orderStatus,orderPaymentChannel);

        PageInfo<SyUserOrder> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }

    /**
     * 退货申请已完成数据
     * @page:页数
     * @limit:条数
     * @return: 退货申请已完成数据
     * */
    @RequestMapping("/getReturning")
    public PageResult<List> getReturning(Integer page, Integer limit){
        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyUserOrder> all = refundService.getReturning();

        PageInfo<SyUserOrder> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     * 退货申请已完成搜索
     * @orderSource:支付方式
     * @orderStatus:订单状态
     * @orderPaymentChannel:订单来源
     * @page:页数
     * @limit:条数
     * @return: 退货申请已完成数据
     * */
    @RequestMapping("/selectReturning")
    public PageResult<List> selectReturning(String orderSource, String orderStatus, String orderPaymentChannel,Integer page, Integer limit){

        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyUserOrder> all = refundService.selectReturning(orderSource,orderStatus,orderPaymentChannel);

        PageInfo<SyUserOrder> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     * 退货申请退款中数据
     * @page:页数
     * @limit:条数
     * @return: 退货申请退款中数据
     * */
    @RequestMapping("/getReturned")
    public PageResult<List> getReturned(Integer page, Integer limit){
        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyUserOrder> all = refundService.getReturned();

        PageInfo<SyUserOrder> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     * 退货申请退款中搜索
     * @orderSource:支付方式
     * @orderStatus:订单状态
     * @orderPaymentChannel:订单来源
     * @page:页数
     * @limit:条数
     * @return: 退货申请退款中数据
     * */
    @RequestMapping("/selectReturned")
    public PageResult<List> selectReturned(String orderSource, String orderStatus, String orderPaymentChannel,Integer page, Integer limit){

        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyUserOrder> all = refundService.selectReturned(orderSource,orderStatus,orderPaymentChannel);

        PageInfo<SyUserOrder> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *退货列表总数
     * @return:退货列表总数
     * */
    @RequestMapping("/number")
    public JsonResult<Integer> number(){
        int a = refundService.Number();
        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }

    /**
     *退货申请待处理总数
     * @return:退货申请待处理总数
     * */
    @RequestMapping("/numberReturnRequest")
    public JsonResult<Integer> numberReturnRequest(){
        int a = refundService.numberReturnRequest();
        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *退货申请已拒绝总数
     * @return:退货申请已拒绝总数
     * */
    @RequestMapping("/numberRefuse")
    public JsonResult<Integer> numberRefuse(){
        int a = refundService.numberRefuse();
        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *退货申请已完成总数
     * @return:退货申请已完成总数
     * */
    @RequestMapping("/numberReturning")
    public JsonResult<Integer> numberReturning(){
        int a = refundService.numberReturning();
        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *退货申请退款中总数
     * @return:退货申请退款中总数
     * */
    @RequestMapping("/numberReturned")
    public JsonResult<Integer> numberReturned(){
        int a = refundService.numberReturned();
        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
}
